New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quote row type field names #1963
Conversation
65e1afc
to
3fab865
Compare
@@ -319,6 +319,11 @@ public void testRowSubscript() | |||
|
|||
// Row subscript in join condition | |||
assertQuery("SELECT n.name, r.name FROM nation n JOIN region r ON ROW (n.name, n.regionkey)[2] = ROW (r.name, r.regionkey)[2] ORDER BY n.name LIMIT 1", "VALUES ('ALGERIA', 'AFRICA')"); | |||
|
|||
// Subscript over field named after reserved keyword | |||
assertQuery( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have a dedicated test for planner (TestPlanner
?). There is no point to run this test for all the connectors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC the issue occurs when distributing plan fragments to workers, so this must run in distributed mode.
presto-tests/src/main/java/io/prestosql/tests/AbstractTestQueries.java
Outdated
Show resolved
Hide resolved
3fab865
to
b5a30ab
Compare
@@ -319,6 +319,11 @@ public void testRowSubscript() | |||
|
|||
// Row subscript in join condition | |||
assertQuery("SELECT n.name, r.name FROM nation n JOIN region r ON ROW (n.name, n.regionkey)[2] = ROW (r.name, r.regionkey)[2] ORDER BY n.name LIMIT 1", "VALUES ('ALGERIA', 'AFRICA')"); | |||
|
|||
// Subscript over field named after reserved keyword | |||
assertQuery( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC the issue occurs when distributing plan fragments to workers, so this must run in distributed mode.
b5a30ab
to
f502d5a
Compare
it already is used to test distribution-related things, eg |
Names can be reserved SQL keywords, so we need to quote them to avoid issues when deserializing plans on workers.
TypeSignature is used for encoding the identity of a type, which is then parsed (for now) using the SQL parser. Since some fields names might collide with SQL reserved words, we need to quote them.
f502d5a
to
9adf159
Compare
Since row type field names can match reserved SQL keywords, names
need to be quoted when rendering them.
Fixes #1962